<?php
$host="localhost";
$username="root";
$pass_word="";
$db="SWGeekStore";
$Conn = mysql_connect( $host,$username,$pass_word) or die ("cannot connect");
mysql_query("SET NAMES utf8",$Conn);
mysql_select_db($db) or die("cannot connect to database"); 


if($_POST){
	
	$catName = $_POST['catName'];
	if(empty($catName)){
    	$errmsg = " Can not add category";
    }
	$sql = "INSERT INTO Category (catName) VALUES ('$catName');";
    mysql_query($sql) or die(mysql_error());
		header("Refresh:3;url=index.php");
		
	
	
}




?>



<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<center>
<table width="427" height="148" border="0">
  <tr>
    <td colspan="2"><strong>Add Category</strong></td>
    </tr>
  <tr>
    <td width="136">Category Name</td>
    <td width="275"><label for="textfield"></label>
      <input type="text" name="catName" id="textfield" /></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label for="textfield2">
      <input type="submit" name="button" id="button" value="Add" />
    </label></td>
    </tr>
</table></center>
